#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int t;
	cin >> t;
	while (t--) {
		string s;
		cin >> s;

		int ans = 1;
		int idx = s.find("1");
		if (idx == -1)
			cout << ans << endl;
		else {
			ans++;
			for (int i = idx; i < s.size();) {
				if (s[i] != '1') {
					ans++;
					i = s.find("1", i);
				} else {
					i++;
				}
			}
			cout << ans << endl;
		}
	}
	return 0;
}
